//package com.qiaodata.datatrans.web;
//
//import com.qiaodata.datatrans.utils.ReadTxtUtil;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestParam;
//import org.springframework.web.bind.annotation.RestController;
//
//import java.io.FileWriter;
//import java.io.IOException;
//import java.io.InputStreamReader;
//import java.io.LineNumberReader;
//import java.util.List;
//
///**
// * Created by Administrator on 2016/12/5 0005.
// */
//@RestController
//@RequestMapping("/shell")
//public class ShellToLinuxController {
//
//    @RequestMapping("/tar")
//    public void doUnTar(@RequestParam("msg") String msg) throws IOException {
//        if (!"starttar".equals(msg)) {
//            return;
//        }
//        //执行tar命令
//        //测试Java读linux系统
//        String start_filePath = "/root/77hh.txt";
//        List<String> ids = ReadTxtUtil.readTxtFile(start_filePath);//按行读取txt文档
//        FileWriter fw1 = new FileWriter("/root/jincheng.txt");//本地模式存储
//        for (String id : ids) {
//            String shellStr = "nohup tar -zxvf /share/20161202/"+id+" &";
//
//            try {
//
//                Process process=Runtime.getRuntime().exec(shellStr);
//                InputStreamReader reader = new InputStreamReader(process.getInputStream());
//                LineNumberReader line = new LineNumberReader(reader);
//                String str;
//                while((str=line.readLine())!=null){
//                    System.out.println(str);
//
//                    fw1.write(str+"\r\n");
//                    fw1.flush();
//                }
//
//            }catch (Exception e){
////                e.printStackTrace();
//                continue;
//            }
//        }
//        fw1.close();
//        System.out.println("done !!!");
//    }
//}
